package com.zy.baselib.widget;

import android.os.Handler;
import android.os.Message;

import androidx.annotation.NonNull;


/**
 * @author: shalei
 * @since: 2020/7/29 2:05 PM
 * @Desc:
 **/
public class MarqueeHandler extends Handler {

    public static final int ROLL_OVER = 100;
    public static final int ROLL_RE = 101;
    private MarqueeView.OnMarqueeListener mOnMarqueeListener;

    public MarqueeHandler(MarqueeView.OnMarqueeListener onMarqueeListener) {
        this.mOnMarqueeListener = onMarqueeListener;
    }

    @Override
    public void handleMessage(@NonNull Message msg) {
        super.handleMessage(msg);
        switch (msg.what) {
            case ROLL_OVER:
                if(mOnMarqueeListener != null) {
                    mOnMarqueeListener.onRollOver();
                }
                break;
            case ROLL_RE:
                if(mOnMarqueeListener != null) {
                    mOnMarqueeListener.onReset();
                }
                break;
        }
    }
}
